package com.itbaizhan.jdkdynaimc2;

import java.lang.reflect.Proxy;

public class Test {
    public static void main(String[] args) {
        //被代理对象
        Apple apple = new AppleImpl();
        //代理方式对象
        ShoppingProxy shoppingProxy = new ShoppingProxy(apple);
        Apple appleJD = (Apple) Proxy.newProxyInstance(
                apple.getClass().getClassLoader(),//类加载器
                apple.getClass().getInterfaces(),//接口
                shoppingProxy      //代理方式对象
        );

        String sell = appleJD.sell(7000);
        System.out.println(sell);
        System.out.println("----------");
        appleJD.repair();
    }
}
